package ge.lowlevel.js.box2d;

import com.google.gwt.core.client.JavaScriptObject;


import ge.engine.Log;
import ge.lowlevel.box2d.RevolutionJointGe;

public class RevolutionJointJs extends RevolutionJointGe
{

	private JavaScriptObject joint;
	public RevolutionJointJs(BoxJs box1, BoxJs box2, double x, double y)
	{
		//does nothing
		super(box1, box2, x, y);
		init(box1, box2, x, y);
	}
	public RevolutionJointJs(WorldJs world, BoxJs box, double x, double y)
	{
		//does nothing
		super(world, box, x, y);
		 
		init(world, box, x, y);
	}
	
	private native void init(WorldJs world, BoxJs box, double x, double y)
	/*-{
			var jointDef = new $wnd.b2RevoluteJointDef();
			
			var world = world.@ge.lowlevel.js.box2d.WorldJs::getWorld()();
			jointDef.anchorPoint.Set(x, y);
			
			jointDef.body1 = world.GetGroundBody();
			jointDef.body2 = box.@ge.lowlevel.js.box2d.BoxJs::getBox()();
			var joint = world.CreateJoint(jointDef);
			this.@ge.lowlevel.js.box2d.RevolutionJointJs::joint = joint;
			
			//$wnd.alert(joint);
	}-*/;
	
	private native void init(BoxJs box1, BoxJs box2, double x, double y)
	/*-{
			var jointDef = new $wnd.b2RevoluteJointDef();
			var world = world.@ge.lowlevel.js.box2d.WorldJs::getWorld()();
			jointDef.anchorPoint.Set(x, y);
			jointDef.body1 = box1.@ge.lowlevel.js.box2d.BoxJs::getBox()();
			jointDef.body2 = box2.@ge.lowlevel.js.box2d.BoxJs::getBox()();
			this.@ge.lowlevel.js.box2d.RevolutionJointJs::joint = world.CreateJoint(jointDef);
	}-*/;

}
